{% extends 'base.html' %}

{% block content %}
    <div class="container">
        <div class="row">
            <div class="col-md-6 col-md-offset-3">
                <form action="" method="post">
                    {% csrf_token %}
                    <div class="form-group">
                        <label for="">书籍名称</label>
                        <input type="text" class="form-control" name="title" value="{{ mod_obj.title }}">
                    </div>
                    <div class="form-group">
                        <label for="">价格</label>
                        <input type="text" class="form-control" name="price" value="{{ mod_obj.price }}">
                    </div>
                    <div class="form-group">
                        <label for="">出版日期</label>
                        <input type="date" class="form-control" name="date" value="{{ mod_obj.pub_date|date:'Y-m-d' }}">
                    </div>
                    <div class="form-group">
                        <label for="">出版社</label>
                        <select class="form-control" name="publish">
                            {% for pub in pub_list %}
                                {% if pub == mod_obj.publish %}
                                    <option value="{{ pub.pk }}" selected>
                                        {{ pub.name }}
                                    </option>
                                {% else %}
                                    <option value="{{ pub.pk }}">
                                        {{ pub.name }}
                                    </option>


                                {% endif %}





                            {% endfor %}
                        </select>

                    </div>
                    <div class="form-group">
                        <label for="">作者</label>
                        <select class="form-control" name="authors" type="text" multiple>
                            {% for aut in aut_list %}
                                {% if aut in mod_obj.authors.all %}
                                    <option value="{{ aut.pk }}" selected>
                                        {{ aut.name }}
                                    </option>
                                {% else %}
                                    <option value="{{ aut.pk }}">
                                        {{ aut.name }}
                                    </option>


                                {% endif %}

                            {% endfor %}
                        </select>

                    </div>

                    <input type="submit" class="btn btn-success pull-right">


                </form>
            </div>
        </div>
    </div>
{% endblock %}